class CGraph {

	private:
	int cV;
	int cE;

	vector< list< int > > gLists;

	public:
	CGraph( int _cV, int _cE );
	~CGraph();

	bool AddEdge( int vSrc, int vDst, int weight );
	bool AddNegEdge( int vSrc, int vDst, int weight );
//	bool DeleteEdge( int vSrc, int vDst );
	int GetCountV();
	int GetCountE();
	int GetWeight( int vSrc, int vDst );
	vector<int> GetNeighbours( int v );
	bool HaveNegCycle();
	bool IsConnected();

	private:
	void DFS( bool * connected, vector< int > neighbours );
}

CGraph::CGraph( int _cV, int _cE ) : cV( _cV ), cE( 0 ) {

}

CGraph::~CGraph() {

	for ( int i=0; i<cV; ++i ) {

		delete [] gMatrix[i];
	}

	delete [] gMatrix;
}

int CGraph::GetCountV() {


	return cV;
}

int CGraph::GetCountE() {


	return cE;
}

int CGraph::GetWeight( int vSrc, int vDst ) {

	for ( int  i=0; i<_cE; ++i ) {

		if ( gMatrix[ vSrc ][ i ] > 0 ) {

			if( gMatrix[ vDst ][ i ] < 0 ) {


				return gMatrix[ vSrc ][ i ];
			}
		}
	}
}

bool CGraph::AddEdge( int vSrc, int vDst, int weight ) {

	if ( vSrc <= cV && vDst <= cV && weight >= 0 ) {

		gLists[ vSrc - 1 ].push_back( vDst - 1 );
		
		++_cE;


		return true;
	}


	return false;
}

bool CGraph::AddNegEdge( int vSrc, int vDst, int weight ) {

	if ( vSrc <= cV && vDst <= cV ) {

		gLists[ vSrc - 1 ].push_back( vDst - 1 );

		++_cE;


		return true;
	}


	return false;
}

list< int > CGraph::Neighbours( int v ) {


	return gLists[ v ];
}

bool CGraph::HaveNegCycle() {

	
}

bool CGraph::IsConnected() {

	bool * connected = new bool[ _cV ];
	vector< int > neighbours;


	con[ 0 ] = true;

	neighbour = GetNeighbour( 0 );

	DFS( connected, neighbours );

	for ( int i=0; i<_cV; ++i ) {

		if( !connected[ i ] ) {


			return false;
		}
	}


	return true;
}

void CGraph::DFS( bool * connected, vector< int > neighbours ) {

	vector< int >::iterator i;


	for ( int i=neighbours.begin(); i<neighbours.end(); ++i ) {

		if ( !connected[ *i ] ) {

			connected[ *i ] = true;

			DFS( connected, neighbours );
		}
	}
}